package com.lcxw.hxzbadmin.controller.chargecontroller;

import com.alibaba.fastjson.JSONObject;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lcxw.hxzbapi.entity.pojo.YwpdChargeDetail;
import com.lcxw.hxzbapi.entity.response.Response;

@RestController
@RequestMapping("/admin/charge/detail")
@CrossOrigin
@Slf4j
public class ChargeDetailController {

    @Resource
    ChargeDetailRealization chargeDetailRealization;

    /**
     * 1、查询充值详情接口
     */
    @PostMapping("/get")
    public Response getChargeDetails(@RequestBody JSONObject requestParams){
        String userId = requestParams.getString("userId");
        String chargeMode = requestParams.getString("chargeMode");
        String startTime = requestParams.getString("startTime");
        String endTime = requestParams.getString("endTime");
        String status = requestParams.getString("status");
        int pageIndex = requestParams.getInteger("pageIndex");
        int pageSize = requestParams.getInteger("pageSize");
        int sum = chargeDetailRealization
            .getSumDetailDync(userId, chargeMode, startTime, endTime, status);
        List<YwpdChargeDetail> chargeDetails = chargeDetailRealization
            .getChargeDetailDync(userId, chargeMode, startTime, endTime, status, pageIndex,
                pageSize);
        Map<String ,Object> data = new HashMap<>();
        data.put("sum",sum);
        data.put("chargeDetails",chargeDetails);
        return Response.ok(data);
    }
}
